<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>公告管理</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<link href="${ctx }/css/style.css" type="text/css" rel="stylesheet" />
		<link href="${ctx }/css/page.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="${ctx }/js/jquery/jquery-1.6.1.min.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#lnkAddNews").click(function() {
					if(window.showModalDialog("${ctx}/news/toAddNews.action","","status=no;dialogWidth=550px;dialogHeight=500px;menu=no;resizeable=yes;scroll=yes;center=yes;edge=raise") == "OK") {
						document.location.href = "${ctx}/news/listAll.action";
					}
				});
			});

			modifyNews = function(id) {
				if(window.showModalDialog("${ctx}/news/toModifyNews.action?id=" + id,"","status=no;dialogWidth=550px;dialogHeight=500px;menu=no;resizeable=yes;scroll=yes;center=yes;edge=raise") == "OK") {
					document.location.href = "${ctx}/news/listAll.action";
				}
			}

			removeNews = function(id) {
				if (confirm('确认要删除么？')) {
					var url = "${ctx}/news/removeNews.action?id=" + id;

					location.href = url;
				}
			}

			publishNews = function(id) {
				var url = "${ctx}/news/publishNews.action?id=" + id;

				location.href = url;
			}
		</script>
	</head>

	<body>
		<s:form id="form1" action="listAll" method="post" namespace="/news">
			<div>
				<div style="width: 99%; height: 30px; text-align: left;">
					当前位置：公告管理
				</div>
				<div style="float: left; width: 59%; background-color: #EDDEA0; height: 30px; text-align: center;">
					<b>公 告 管 理</b>
				</div>
				<div style="float: right; width: 39%; background-color: #EDDEA0; height: 30px; text-align: center">
					<a href="#" id="lnkAddNews">&nbsp;
						<img src="${ctx }/images/write.gif" style="border: 0" width="16px" height="16" alt="" />
						<u>添加新公告</u>
					</a>
				</div>

				<div style="width: 100%; background-color: #FBF7E6">
					<div>
						<table cellspacing="2" cellpadding="3" border="1" style="background-color:#DEBA84;border-color:#DEBA84;border-width:1px;border-style:None;width:100%;">
							<thead>
								<tr style="color:White;background-color:#A55129;font-weight:bold; font-size: 11px;">
									<th style="width: 15%">公告标题</th>
									<th>公告内容</th>
									<th style="width: 20%">公告发布时间</th>
									<th style="width: 15%">操作</th>
									<th style="width: 15%">确定发布</th>
								</tr>
							</thead>
							<tbody>
								<s:if test="page.data.size() == 0">
									<tr style="color:#000066;background-color:#FFF7E7; font-size: 13px; text-align: center;">
										<td colspan="5">暂无记录显示！</td>
									</tr>
								</s:if>
								<s:else>
									<s:iterator value="page.data">
										<tr style="color:#000066;background-color:#FFF7E7; font-size: 13px;">
											<td>
												<s:property value="title" />
											</td>
											<td>
												<s:property value="content" />
											</td>
											<td align="center">
												<fmt:formatDate value="${createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
											</td>
											<td align="center">
												<span>
													<s:if test="%{@com.gamecard.common.Constants@NEWS_STATE_NO_PUBLISH == state}">
														<a href="#" onclick="modifyNews('<s:property value="id" />');">
															<font color="blue">修改</font>
														</a>
													</s:if>
													<s:else>修改</s:else>
													|
													<a href="#" onclick="removeNews('<s:property value="id" />');">
														<font color="blue">删除</font>
													</a>
												</span>
											</td>
											<td align="center">
												<s:if test="%{@com.gamecard.common.Constants@NEWS_STATE_NO_PUBLISH == state}">
													<input type="button" value="发布" style="cursor: hand;" class="buttonface" onclick="publishNews('<s:property value="id" />');" />
												</s:if>
												<s:else>
													<input type="button" value="发布" style="cursor: hand;" class="buttonface" disabled="disabled" />
												</s:else>
											</td>
										</tr>
									</s:iterator>
								</s:else>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="5" align="center">
										<gc:page pageSize="${page.pageSize}" 
											totalCount="${page.totalCount}" 
											formId="form1" 
											totalPageCount="${page.totalPageCount}" 
											currentPageNo="${page.currentPageNo}" />
									</td>
								</tr>
							</tfoot>
						</table>
					</div>
				</div>
			</div>
		</s:form>
	</body>
</html>
